function addLayer(url,id){
    var url = getContextPath() +  url;
    if(id){
        if(url.indexOf("?")>-1){
            url += '&id=' + id;
        }else{
            url += '?id=' + id;
        }
    }
    layer.open({
        title : "添加修改详情信息",
        type: 2,
        area: ['95%', '95%'],
        anim: 2,
        content: [url, 'yes']
    });
}

function modi(url){
    var checkStatus = table.checkStatus('tableList')
        ,data = checkStatus.data;
    if(data.length == 0 || data.length > 1){
        layer.msg("请选择一条数据");
        return false;
    }
    addLayer(url,data[0].id);
}

function deleteById(data, obj, url){
    layer.confirm('真的删除此项记录么', function(index){
        $ajax({
            url: url,
            data: {
                id : data.id
            },
            succCallback: function (json) {
                if(json.code == 0){
                    obj.del();
                }
            }
        });
    });
}

function deleteBatch(url){
    var checkStatus = table.checkStatus('tableList')
        ,data = checkStatus.data;
    var ids = "";
    if(data.length == 0 ){
        layer.msg("请至少选择一条数据");
        return false;
    }else{
        for (var i = 0; i < data.length; i++) {
            ids += data[i].id;
            if(i != (data.length -1))
                ids += ",";
        }
    }
    layer.confirm('您确定要批量删除信息吗？此操作不可逆转，请谨慎使用！', function(index){
        $ajax({
            url: url,
            data :  {
                "ids" : ids
            },
            succCallback: function (json) {
                if(json.code == 0){
                    reload();
                }
            }
        });
    });
}